package model.dao;

import java.sql.ResultSet;
import java.util.ArrayList;

import controller.util.ControllerHelper;

import model.pojo.NhanVien;
import model.util.DataHelper;

public class NhanVienDAO {
	public static NhanVien KiemTraDangNhap(String userName, String pass)
	{
		NhanVien nv = new NhanVien();
		DataHelper helper = new DataHelper();
        try
        {
            helper.open();
            ArrayList<Object> para = new ArrayList<Object>();
            para.add(userName);
            para.add(pass);
            String sp = ControllerHelper.getStoreProcedureString("KiemTraDangNhap");
            ResultSet result = helper.executeProcedure(sp, para);
            if(result.next())
            {
               nv.setDangNhap(true);
               nv.setDangNhapLanCuoi(result.getString("DangNhapLanCuoi"));
               nv.setHoTen(result.getString("TenDangNhap"));
               nv.setMatKhau(result.getString("MatKhau"));
               nv.setHoTen(result.getString("HoTen"));
            }
            
        }catch(Exception ex)
        {
            System.out.println(ex.getMessage());
        }
        finally
        {
            helper.close();
        }
		return nv;
	}

}
